Lab 29

Graphical User Interfaces (GUI's) and guide

CS211 Lab Policy:

Instructions:

Use MATLAB's guide tool to create the files Lab29.m and Lab29.fig.  This simple GUI will count the number of times a user clicks a button.

  1. Using guide, create a simple GUI that contains the three components listed below. A picture of the desired GUI is shown below as well.

  1. Set the following property values of the 3 components:

  1. Add code to the callback function Click_Button_callback() to increment the displayed number of clicks.
     

    % Get the current value of the number of button clicks
    Count = str2num(get(handles.Count_label, 'String'));

    % Increment the count value
    Count = Count + 1;

    % Change the value that is displayed in the GUI
    set(handles.Count_label, 'String', num2str(Count))
     

  2. Run and test your GUI program .
     

  3. Add a second push button to your GUI and label it 'Reset'. Then add code to its callback function that resets the counter back to zero. A picture of what this might look like is shown below.


     

  4. In your 'Click Button' callback function, display the entire contents of the handles argument (i.e., disp(handles) ). Run your program and examine the output. Make sure you understand that the handles structure allows you to access all components of your GUI program from any callback function.

    Now display all the properties of one of your GUI components. For example, disp( set(handles.Click_Button) ). Run your program and examine the output. Make sure you understand that any property of any component can be changed at any time during the execution of a GUI program. After you are finished investigating the outputs, you can comment out these disp() statements.

 

Turn-in:

Submit your Lab29.m and Lab29.fig files.